//
//  GRJLoadImageManager.m
//  GRJTolCayFrwk
//
//  Created by apple on 2017/3/1.
//  Copyright © 2017年 Global Barter. All rights reserved.
//
// 整个app加载图片，全部使用这个类去加载


#import "GRJLoadImageManager.h"



@implementation GRJLoadImageManager


+ (void)grj_setImageWithURL:(NSString *)urlStr placeholderImage:(UIImage *)placeholder progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDExternalCompletionBlock)completedBlock imageView:(UIImageView *)imageView
{
    
    // 判断下 SDWebImage有没有做过缓存，如果做过，就直接获取缓存图片，就不需要加载
    UIImage *cacheImage = [[SDImageCache sharedImageCache] imageFromDiskCacheForKey:urlStr];
    
    // 优化不需要每次都裁剪大图片
    if (cacheImage) {
        // 加载图片，播放gif功能
        // sd_setImageWithURL:已经帮你做好处理，如果有缓存的图片，就不会去加载
        [imageView sd_setImageWithURL:[NSURL URLWithString:urlStr]];
        // imageView.image = cacheImage;
        
    } else {
        // 加载图片
        [imageView sd_setImageWithURL:[NSURL URLWithString:urlStr] placeholderImage:placeholder options:SDWebImageRetryFailed progress:progressBlock completed:completedBlock];
    }
    
}

@end
